package klimuts.periodicals.admin.actions;

import klimuts.periodicals.data.DataSource;
import klimuts.periodicals.user.User;

import com.opensymphony.xwork2.ActionSupport;

/**
 *  Action retrieve id from URL and load {@link User} from database
 *  by it.
 * @author Klimuts Siarhei
 * 
 */
public class ShowUser extends ActionSupport {
	private long id;
	private User user;
	
	public String execute() throws Exception {
		user=DataSource.getUser(id);
		if (user!=null)
			return "success";
		else {
			addActionError(getText("admin.user.error"));
			return "error";
		}
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
